package com.x.reader.dao;

import com.x.framework.Base;
import com.x.framework.dao.BaseDao;
import com.x.reader.model.App;
import com.x.reader.model.Audio;
import com.x.reader.model.AudioChapter;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class AppDao extends BaseDao {

    private final static String selectAppListSql = "select t1.* from reader_app t1 where 1 = 1 ";

    public List<App> selectAppList(App app) throws Exception {
        StringBuilder sb = new StringBuilder(selectAppListSql);
        List params = new ArrayList();
        if (Base.isNotNull(app.getAppKey())) {
            sb.append("and t1.app_key = ? ");
            params.add(app.getAppKey());
        }
        if (Base.isNotNull(app.getAppSeq())) {
            sb.append("and t1.app_seq = ? ");
            params.add(app.getAppSeq());
        }
        sb.append("order by t1.app_seq desc");
        return this.queryForList(sb.toString(), App.class, params);
    }

}
